package com.pi.iot.repository.huawei.util;

import java.text.MessageFormat;

/**
 * @Description iot平台的api管理类
 * @author chenmf
 * @date 时2018年12月28日01:43:22
 */
public class PlatformUriManager {
//  获取token授权
  public static final String APP_AUTH = "/iocm/app/sec/v1.1.0/login";
//  刷新token有效期
  public static final String REFRESH_TOKEN = "/iocm/app/sec/v1.1.0/refreshToken";
//  设备注册
  public static final String REGISTER_DEVICE = "{0}/iocm/app/reg/v1.1.0/devices";
//  更新设备信息
  public static final String MODIFY_DEVICE_INFO = "{0}/iocm/app/dm/v1.1.0/devices/{1}?appId={2}";
//  查询设备状态
  public static final String QUERY_DEVICE_ACTIVATION_STATUS = "/iocm/app/reg/v1.1.0/devices";
//  设备移除 0. host 1.deviceId, 2. appId
  public static final String DELETE_DEVICE = "{0}/iocm/app/dm/v1.1.0/devices/{1}?appId={2}&cascade=false";
//  发现非直连设备
  public static final String DISCOVER_INDIRECT_DEVICE = "/iocm/app/signaltrans/v1.1.0/devices/%s/services/%s/sendCommand";
//  移除非直连设备
  public static final String REMOVE_INDIRECT_DEVICE = "/iocm/app/signaltrans/v1.1.0/devices/%s/services/%s/sendCommand";

//  查询设备信息, deviceId , appId
  public static final String QUERY_DEVICES = "{0}/iocm/app/dm/v1.3.0/devices/{1}?appId={2}";//&cascade=false
//  查询网关设备
  public static final String QUERY_GATEWAY_DEVICES = "{0}/iocm/app/dm/v1.3.0/devices?appId={1}&deviceType=DoorLock&pageNo=0&pageSize=200";//&cascade=false
//  查询设备数据
  public static final String QUERY_DEVICE_DATA = "/iocm/app/dm/v1.3.0/devices";
//  查询设备历史数据
  public static final String QUERY_DEVICE_HISTORY_DATA = "/iocm/app/data/v1.1.0/deviceDataHistory";
//  查询设备能力
  public static final String QUERY_DEVICE_CAPABILITIES = "/iocm/app/data/v1.1.0/deviceCapabilities";
//  通知订阅
  public static final String SUBSCRIBE_NOTIFYCATION = "/iocm/app/sub/v1.1.0/subscribe";
//  发送异步命令
  public static final String POST_ASYN_CMD = "/iocm/app/cmd/v1.4.0/deviceCommands";
// 设备查询指令
  public static final String QUERY_DEVICE_CMD = "/iocm/app/cmd/v1.4.0/deviceCommands";
//  修改设备信息指令
  public static final String UPDATE_ASYN_COMMAND = "/iocm/app/cmd/v1.4.0/deviceCommands/%s";
//  指令撤销  
  public static final String CREATE_DEVICECMD_CANCEL_TASK = "/iocm/app/cmd/v1.4.0/deviceCommandCancelTasks";
  public static final String QUERY_DEVICECMD_CANCEL_TASK = "/iocm/app/cmd/v1.4.0/deviceCommandCancelTasks";
  public static String getAppAuth(String host) {
    return host + APP_AUTH;
  }
  public static String getRefreshToken(String host) {
    return host + REFRESH_TOKEN;
  }
  public static String getRegisterDevice(String host) {
    return MessageFormat.format(REGISTER_DEVICE, new Object[]{host});
  }
  public static String getModifyDeviceInfo(String host,String deviceId, String appId) {
    Object[] arguments = new Object[]{host, deviceId, appId};
    return MessageFormat.format(MODIFY_DEVICE_INFO, arguments) ;
  }
  public static String getQueryDeviceActivationStatus(String host) {
    return host + QUERY_DEVICE_ACTIVATION_STATUS;
  }
  public static String getDeleteDevice(String host, String appId, String deviceId) {
    Object[] arguments = new Object[]{host, deviceId, appId};
    return MessageFormat.format(DELETE_DEVICE, arguments) ;
  }
  public static String getDiscoverIndirectDevice(String host) {
    return host + DISCOVER_INDIRECT_DEVICE;
  }
  public static String getRemoveIndirectDevice(String host) {
    return host + REMOVE_INDIRECT_DEVICE;
  }
  public static String getQueryDevices(String host, String deviceId, String appId) {
    Object[] arguments = new Object[]{host, deviceId, appId};
    return MessageFormat.format(QUERY_DEVICES, arguments) ;
  }
  public static String getQueryGatewayDevices(String host, String appId) {
    Object[] arguments = new Object[]{host, appId};
    return MessageFormat.format(QUERY_GATEWAY_DEVICES, arguments);
  }
  public static String getQueryDeviceData(String host) {
    return host + QUERY_DEVICE_DATA;
  }
  public static String getQueryDeviceHistoryData(String host) {
    return host + QUERY_DEVICE_HISTORY_DATA;
  }
  public static String getQueryDeviceCapabilities(String host) {
    return host + QUERY_DEVICE_CAPABILITIES;
  }
  public static String getSubscribeNotifycation(String host) {
    return host + SUBSCRIBE_NOTIFYCATION;
  }
  public static String getPostAsynCmd(String host) {
    return host + POST_ASYN_CMD;
  }
  public static String getQueryDeviceCmd(String host) {
    return host + QUERY_DEVICE_CMD;
  }
  public static String getUpdateAsynCommand(String host) {
    return host + UPDATE_ASYN_COMMAND;
  }
  public static String getCreateDevicecmdCancelTask(String host) {
    return host + CREATE_DEVICECMD_CANCEL_TASK;
  }
  public static String getQueryDevicecmdCancelTask(String host) {
    return host + QUERY_DEVICECMD_CANCEL_TASK;
  }
}
